const _ = require('lodash');
const obj = {
  a: 11,
  b: '',
  c: {
    dd: 3333,
    cc: {
      kk: 90,
    },
  },
};

console.log(_.get(obj, ['kk']));

const getObjectValue = (obj, key) => {
  if (!obj) {
    return;
  }
  const getValue = (obj, key) => {
    let value;
    Object.keys(obj).forEach((k) => {
      if (k === key) {
        value = obj[k];
      } else if (Object.prototype.toString.call(obj[k]) === '[object Object]') {
        value = getValue(obj[k], key);
      }
    });
    return value;
  };
  // eslint-disable-next-line consistent-return
  return getValue(obj, key);
};

console.log(getObjectValue(obj, 'kk'));
function func() {
  for (var i = 0; i <= 10; i++) {
    var a = i + 2;
  }
  console.log(i, a);
}
func();

function P() {
  var a = 0;
  this.getA = function () {
    return a;
  };
}

var p = new P();
console.log(p.getA());
var f = p.getA;
console.log(f());

const a = 11;
const b = 22;

function test1() {
  const c = 11;
  var d = 123;
  let e = 456;
  function test2() {
    let f = 34;
    let g = 4;
    console.dir(test2);
    console.log(c, d);
    function test3() {
      let t = 2;
      console.dir(test3);
    }
    test3();
  }

  test2();
  console.dir(test1);
}

test1()
